debian: Run tests under wayland too in linux
authorMarco Trevisan (Treviño) <mail@3v1n0.net>
Thu, 8 Jul 2021 14:22:45 +0000 (16:22 +0200)
committerMarco Trevisan (Treviño) <marco@ubuntu.com>
Fri, 9 Jul 2021 14:02:45 +0000 (16:02 +0200)
It's now becoming the default backend so better to also test the library
there.

debian/control
debian/control.in
debian/log-reftests.py
debian/rules
debian/run-tests.sh
debian/tests/run-with-display [new file with mode: 0755]

index 0db4754df7eabc681be62046c6224d1bd1e0370f..3108cd5858574afa7fd72d8c3738424c8ba10211 100644 (file)
@@ -55,6 +55,7 @@ Build-Depends: adwaita-icon-theme <!nocheck>,
                sassc,
                ttf-bitstream-vera <!nocheck>,
                wayland-protocols (>= 1.21) [linux-any],
+               weston [linux-any] <!nocheck>,
                xauth <!nocheck>,
                xsltproc,
                xvfb <!nocheck>,
index c7c1ee317e08b0180e65cb866d01cac33bccd07b..eed246eb176173108b2ad749e7002c7fe0b4a5bd 100644 (file)
@@ -55,6 +55,7 @@ Build-Depends: adwaita-icon-theme <!nocheck>,
                sassc,
                ttf-bitstream-vera <!nocheck>,
                wayland-protocols (>= 1.21) [linux-any],
+               weston [linux-any] <!nocheck>,
                xauth <!nocheck>,
                xsltproc,
                xvfb <!nocheck>,
index b06c8d892f1a661204f374fcddb41d9a8c4d2d2b..50ff417cd8a27e2d28bf903ac88ff35fa4d878b6 100755 (executable)
@@ -11,11 +11,11 @@ if __name__ == '__main__':
         for outputs in (
             Path(
                 'debian', 'build', 'deb', 'testsuite', 'gsk', 'compare',
-                'opengl', 'x11',
+                'opengl', 'x11', 'wayland'
             ),
             Path(
                 'debian', 'build', 'deb', 'testsuite', 'gsk', 'compare',
-                'broadway', 'x11',
+                'broadway', 'x11', 'wayland'
             ),
         ):
             diff = (outputs / (node.stem + '.diff.png'))
@@ -39,7 +39,7 @@ if __name__ == '__main__':
         for outputs in (
             Path(
                 'debian', 'build', 'deb', 'testsuite', 'reftests',
-                'output', 'x11',
+                'output', 'x11', 'wayland'
             ),
         ):
             diff = (outputs / (ui.stem + '.diff.png'))
index 6913ea62d07485c49e1aa3f326e995c0c107f9d1..1d288616bed6796875fc2a00f694f765a46bd839 100755 (executable)
@@ -173,8 +173,13 @@ ifneq ($(filter %-udeb,$(built_binaries)),)
        dh_auto_build --builddirectory=debian/build/udeb
 endif
 
+test_backends = x11
 test_timeout_multiplier = 1
 
+ifeq (linux,$(DEB_HOST_ARCH_OS))
+       test_backends += wayland
+endif
+
 ifneq ($(filter arm hppa mips% sparc%,$(DEB_HOST_ARCH_CPU)),)
 $(info Slow architecture detected, increasing test timeout)
 test_timeout_multiplier = 10
@@ -204,11 +209,15 @@ xfail_reftests = \
 #             gtk:gsk+gsk-compare+gsk-broadway+gsk-compare-broadway / broadway blend-normal
 #             gtk:gsk+gsk-compare+gsk-broadway+gsk-compare-broadway / broadway blend-difference
 # s390x: many (endianness?)
+
 override_dh_auto_test:
-       env BUILDDIR=debian/build/deb \
-               FUZZY_REFTESTS="$(fuzzy_reftests)" \
-               XFAIL_REFTESTS="$(xfail_reftests)" \
-                       debian/run-tests.sh -t $(test_timeout_multiplier)
+       set -e; for backend in $(test_backends); do \
+               env BUILDDIR=debian/build/deb \
+                       FUZZY_REFTESTS="$(fuzzy_reftests)" \
+                       XFAIL_REFTESTS="$(xfail_reftests)" \
+                       BACKEND=$$backend \
+                               debian/run-tests.sh -t $(test_timeout_multiplier); \
+       done
 
 override_dh_auto_install:
        dh_auto_install --builddirectory=debian/build/deb --destdir=debian/install/deb
index aee985d08a251a9a0e9fcab09496a297e7c3f5f9..e0ece616c2bab8181005ac43032b432d2a8a4b28 100755 (executable)
@@ -48,7 +48,7 @@ env \
     GIO_USE_VFS=local \
     GIO_USE_VOLUME_MONITOR=unix \
     dbus-run-session -- \
-        xvfb-run -a -s "-screen 0 1024x768x24 -noreset" \
+        debian/tests/run-with-display "$BACKEND" \
             debian/tests/run-with-locales \
                 --generate de_DE.UTF-8 \
                 --generate en_GB.UTF-8 \
diff --git a/debian/tests/run-with-display b/debian/tests/run-with-display
new file mode 100755 (executable)
index 0000000..3fa2d46
--- /dev/null
@@ -0,0 +1,67 @@
+#!/bin/sh
+# vim:set sw=4 sts=4 et:
+#
+# Run a wrapped command in a fake display environment
+#
+# Copyright 2021 Marco Trevisan <marco@ubuntu.com>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# Assume a Debian Policy §10.4-compatible shell like dash or bash (with the
+# 'local' builtin)
+# shellcheck disable=SC2039
+
+set -e
+
+me="$(basename "$0")"
+
+usage () {
+    local status="${1-2}"
+
+    if [ "$status" -ne 0 ]; then
+        exec >&2
+    fi
+
+    echo "Usage: $me [wayland|x11] COMMAND [ARGS...]"
+    exit "$status"
+}
+
+display="$1"
+
+case "$display" in
+    wayland)
+        shift
+        if [ -z "$XDG_RUNTIME_DIR" ]; then
+            our_xrd="$(mktemp -d -t xdg-runtime-XXXXXXXX)"
+            export XDG_RUNTIME_DIR="$our_xrd"
+        fi
+        if ! command -v weston > /dev/null; then
+            echo "No weston available"
+            exit 1
+        fi
+        socket="wayland-$(od -vAn -N1 -tu1 < /dev/urandom | tr -d '[:space:]')"
+        weston --backend=headless-backend.so --socket="$socket" --idle-time=0 2>&1 &
+        weston_pid=$!
+        trap 'kill $weston_pid; [ -n $our_xrd ] && rm -rfv $our_xrd' EXIT INT
+        while [ ! -S "$XDG_RUNTIME_DIR/$socket" ]; do
+            echo "Waiting for socket..."
+            sleep 1
+        done
+        env -u DISPLAY WAYLAND_DISPLAY="$socket" "$@"
+        exit $?
+    ;;
+    x11)
+        shift
+        if ! command -v xvfb-run > /dev/null; then
+            echo "No xvfb-run available"
+            exit 1
+        fi
+        exec env -u WAYLAND_DISPLAY xvfb-run -a -s "-screen 0 1024x768x24 -noreset" "$@"
+    ;;
+    -h|--help|help)
+        usage 0
+        ;;
+    *)
+        usage 2
+        ;;
+esac